import { Routes } from '@angular/router';
import { tableDemoTableConfigResolver } from './pages/table-demo/table-demo-table-config.resolver';

/**
 * Home 模块路由配置
 * 
 * 该文件允许 Home 模块独立管理自己的路由，
 * 包括首页、组件展示、表单、异常页面等功能路由
 */
export const HOME_ROUTES: Routes = [
  // 根路径重定向 - 必要！确保访问 / 时重定向到 /home
  {
    path: '',
    redirectTo: 'home',
    pathMatch: 'full'
  },
  {
    path: 'home',
    loadComponent: () => import('../dashboard/dashboard.component').then(m => m.DashboardComponent),
    title: '首页',
    data: {
      breadcrumb: {
        menuId: 'home'
      }
    }
  },
  {
    path: 'i18n-guide',
    loadComponent: () => import('./pages/i18n-guide/i18n-guide.component').then(m => m.I18nGuideComponent),
    title: '国际化指南',
    data: {
      breadcrumb: {
        menuId: 'i18n-guide'
      }
    }
  },
  {
    path: 'rxjs-guide',
    loadComponent: () => import('./pages/rxjs-guide/rxjs-guide.component').then(m => m.RxjsGuideComponent),
    title: 'RxJS 指南',
    data: {
      breadcrumb: {
        menuId: 'rxjs-guide'
      }
    }
  },
  {
    path: 'components',
    data: {
      breadcrumb: {
        menuId: 'components'
      }
    },
    children: [
      {
        path: 'material-ui',
        loadComponent: () => import('./pages/material-ui/material-ui.component').then(m => m.MaterialUiComponent),
        title: 'Material 组件',
        data: {
          breadcrumb: {
            menuId: 'material-ui'
          }
        }
      },
      {
        path: 'dialogs',
        loadComponent: () => import('./pages/dialogs/dialogs.component').then(m => m.DialogsComponent),
        title: '弹窗演示',
        data: {
          breadcrumb: {
            menuId: 'dialogs'
          }
        }
      },
      {
        path: 'table-demo',
        loadComponent: () => import('./pages/table-demo/table-demo.component').then(m => m.TableDemoComponent),
        title: '表格组件演示',
        resolve: {
          tableConfig: tableDemoTableConfigResolver
        },
        data: {
          breadcrumb: {
            menuId: 'table-demo'
          }
        }
      }
    ]
  },
  {
    path: 'material-icons',
    loadComponent: () => import('./pages/material-icons/material-icons.component').then(m => m.MaterialIconsComponent),
    title: '图标库',
    data: {
      breadcrumb: {
        menuId: 'material-icons'
      }
    }
  },
  {
    path: 'forms',
    data: {
      breadcrumb: {
        menuId: 'forms'
      }
    },
    children: [
      {
        path: 'basic',
        loadComponent: () => import('./pages/forms/basic-form/basic-form.component').then(m => m.BasicFormComponent),
        title: '基础表单',
        data: {
          breadcrumb: {
            menuId: 'basic-form'
          }
        }
      },
      {
        path: 'step',
        loadComponent: () => import('./pages/forms/step-form/step-form.component').then(m => m.StepFormComponent),
        title: '分步表单',
        data: {
          breadcrumb: {
            menuId: 'step-form'
          }
        }
      },
      {
        path: 'advanced',
        loadComponent: () => import('./pages/forms/advanced-form/advanced-form.component').then(m => m.AdvancedFormComponent),
        title: '高级表单',
        data: {
          breadcrumb: {
            menuId: 'advanced-form'
          }
        }
      }
    ]
  },
  {
    path: 'exception',
    data: {
      breadcrumb: {
        menuId: 'exception'
      }
    },
    children: [
      {
        path: '403',
        loadComponent: () => import('./pages/exception/403/exception-403.component').then(m => m.Exception403Component),
        title: '403错误',
        data: {
          breadcrumb: {
            menuId: '403'
          }
        }
      },
      {
        path: '404',
        loadComponent: () => import('./pages/exception/404/exception-404.component').then(m => m.Exception404Component),
        title: '404错误',
        data: {
          breadcrumb: {
            menuId: '404'
          }
        }
      },
      {
        path: '500',
        loadComponent: () => import('./pages/exception/500/exception-500.component').then(m => m.Exception500Component),
        title: '500错误',
        data: {
          breadcrumb: {
            menuId: '500'
          }
        }
      }
    ]
  },
  {
    path: 'mock-auth',
    loadComponent: () => import('./pages/mock-auth/mock-auth.component').then(m => m.MockAuthComponent),
    title: '模拟认证',
    data: {
      breadcrumb: {
        menuId: 'mock-auth'
      }
    }
  }
];
